package org.mitoma.logger.client;

import org.mitoma.logger.shared.AuthInfo;
import org.mitoma.logger.shared.User;

import com.google.gwt.core.client.GWT;

public class GlobalRepository {

  private static AuthInfo           info      = null;
  private static MainPanel          mainPanel = new MainPanel();
  private static LoggerServiceAsync service   = GWT.create(LoggerService.class);

  public static void setAuthInfo(AuthInfo info) {
    GlobalRepository.info = info;
  }

  public static String getSessionId() {
    return info.getSession().getId();
  }

  public static User getUser() {
    return info.getUser();
  }

  public static MainPanel getMainPanel() {
    return mainPanel;
  }

  public static void setMainPanel(MainPanel mainPanel) {
    GlobalRepository.mainPanel = mainPanel;
  }

  public static LoggerServiceAsync getService() {
    return service;
  }

  public static void setService(LoggerServiceAsync service) {
    GlobalRepository.service = service;
  }

  public static void moveToTop() {
    getMainPanel().login.clear();
    getMainPanel().login.add(new UserInfoPanel());
    getMainPanel().content.clear();
    getMainPanel().content.add(new LoggerListPanel());
  }

  public static void moveToRegisterComplete() {
    getMainPanel().login.clear();
    getMainPanel().login.add(new UserInfoPanel());
    getMainPanel().content.clear();
    getMainPanel().content.add(new RegisterCompletePanel());
  }

  public static void moveToSelectLogger() {
    getMainPanel().content.clear();
    getMainPanel().content.add(new SelectLoggerPanel());
  }

}
